package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class TestNote {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        FileOutputStream fos = new FileOutputStream("note.txt");//新建文件夹不需要放入循环体
        System.out.println("请输入内容，输入exit退出");
        while (true) { //直到...如何如何，用自造死循环
           //自造死循环，先写循环中断的条件
            String line = scan.nextLine().trim();
            if (line.equals("exit")) {
                break;
            }
            fos.write(line.getBytes(StandardCharsets.UTF_8));//将输出的内容转成utf码
        }
        System.out.println("程序结束");
        fos.close();



    }
}
